#include "util.hpp"
#include <iostream>
#include <stdio.h>
#include <unistd.h>
int main() {
  setNonBlock(0);
  char buffer[1024];

  while (1) {
    printf("<< ");
    fflush(stdout);
    ssize_t bytes_read = read(0, buffer, sizeof(buffer) - 1);
    if (bytes_read > 0) {
      buffer[bytes_read - 1] = 0;
      std::cout << "echo#" << buffer << std::endl;
    } else if (bytes_read == 0) {
      std::cout << "end" << std::endl;
      break;
    } else {
      std::cout << "------" << std::endl;
    }
    sleep(1);
  }

  return 0;
}